Not today...

Filed under bash...

comments

Snippet

Bash base64 padding

Disclaimer: I am not 100% percent sure of my formula. It works every time I use it but I may have misunderstood some concepts. Take this article with a grain of salt. It happens that sometimes I have to process some base64 encoded strings which are not padded correctly (here is the wikipedia explanation of base64 padding). When using the base64 -d command I end up getting the following error: base64: invalid input and a non zero exit code. Read More...

Tagged bash

comments

Snippet

Install custom certificate with mkcert

Following my previous post about generating a custom root certificate and a PKI. I will share today a small snippet to install your self made certificate on your laptop (or fleet) to be used by the system or the browsers. It works on OSX, Linux and Windows by using a nice hidden feature of mkcert. Following the documentation, we can see that we can install a certificate from a custom location. Read More...

Tagged bash , admin

comments

Snippet

Socat, Telnet and Unix sockets

Once in a while I use telnet, mostly to check if a port is open (the infamous telnet localhost 22) and sometimes to send a random http request. However, telnet has a few caveats which are: not able to read from stdin not able to deal with https not able to handle unix sockets Those limitations are pushing me towards the use of the socat utility. Here I will show a few situations in which I am now using socat. Read More...

Tagged cli , admin , bash

comments

OS

Bash process substitution failure

This is just a problem I encountered running my Alpine box, so I publish the fix for others to not loose time like I did. I had a software that came with a bash script and got a problem when I tried to run it. It was failing with the following error: fopen: No such file or directory I added the magical set -x line at the beginning to understand what was going on. Read More...

Tagged bash

comments

Snippet

RSA OAEP in Go and Openssl equivalent

From time to time you write some code to deal with data that will be stored somewhere on a drive. When debugging it may be nice to have “shell” commands to mimic code and help understanding what is going on. When it comes to encryption the swiss army knife you will most probably have in your shell environment is openssl. But reading and understanding the documentation can sometimes be “challenging”. Read More...

Tagged golang , bash

comments

Snippet

direnv

I recently discovered the direnv project. Which helped me a lot for setting up my development environments. I will share a bit of things I use in my daily basis. Python projects This is well documented but here is what I use in python projects to set up a default virtualenv. layout python That’s it! It sets up a virtualenv in your .direnv directory, and load the updated PATH. Golang projects This one is a bit trickier. Read More...

Tagged bash , cli , dev

comments

os

Start libvirt VM as unprivileged user

Quick post for starting a VM inside libvirt as a non-root user. Also contains some useful snippets. I want to start an alpine virt iso (from here) inside kvm through libvirt. But I am sick to run all my virsh commands prefixed with sudo. DISCLAIMER: This will contain some of my conclusions with my partial understanding of those tools. I am quite sure that all of this can be improved, but I don’t have time to invest on this for the moment. Read More...

Tagged admin , bash

comments

OS

Bash Shortcuts

Here is just a small reminder of common bash shortcuts for everyday use: Ctrl + A Go to the beginning of the line you are currently typing on Ctrl + E Go to the end of the line you are currently typing on Ctrl + L Clears the Screen, similar to the clear command Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line. Read More...

Tagged bash , cli

comments

Snippet

Curl utils

Here are some options and command I use with curl when dealing with stuff I have to develop. curl -si <ip> # -s is the silent flag, it removes the progress # -i displays the headers curl -X POST -H "Content-Type: application/json" -u "admin:admin" -d '{}' <ip> # -X set up the http method (here POST) # -H set up an header, format is: "header_name: value" # -u support for Basic Auth, format is: "user:password" # -d set up data to send to the server I mostly use those options, the -s is really interesting when you want to grep the content. Read More...

Tagged bash

comments

Snippet

Bash Expansion

A small post just to share a useful bashism the Brace Expansion. It is really simple to make it works: for i in {1..50} do echo "Hello World $i" done It will print fifty “Hello World”. Ok it seems cool but not amazing? Ok, now the second feature echo something/{foo,bar} > something/foo something/bar Still not amazed, ok now type this one: cp some_file{,.old} It will copy your file adding a . Read More...

Tagged bash , cli